package cn.line5.seam.example;

import java.util.List;

import cn.line5.seam.annotations.In;
import cn.line5.seam.annotations.Name;
import cn.line5.seam.annotations.Transaction;
import cn.line5.seam.db.IDGenerator;
import cn.line5.seam.db.PageResult;

@Name("testService")
/**
 * <h1>LSEAM框架示例业务层实现类</h1>
 * 
 * @author Liu,Xiaojun
 */
public class TestServiceImpl implements TestService {
	@In("testDao")
	private TestDao testDao;

	public List<TestVo> getList() {
		return this.testDao.getList();
	}

	public PageResult<TestVo> getPageList(String currentPage) {
		return this.testDao.getPageList(currentPage);
	}

	public TestVo getUser(String id) {
		return this.testDao.getUser(id);
	}

	public boolean saveUser(TestVo vo) {
		if (vo.getUserId() != null) {
			return this.testDao.modifyUser(vo);
		} else {
			vo.setUserId(IDGenerator.UUID());
			return this.testDao.insertUser(vo);
		}
	}

	@Transaction
	public boolean deleteUser(String[] ids) {
		boolean t = true;
		for (String id : ids) {
			t &= this.testDao.deleteUser(id);
		}
		return t;
	}

	public boolean deleteUser(String id) {
		return this.testDao.deleteUser(id);
	}
}
